<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <cpn :cmusics='musics' :cmessage='message'></cpn>
    </div>

    <template id="cpn">
        <div>
            <ul>
                <li v-for='(item,index) in cmusics'>{{item}}</li>
            </ul>
            <h2>{{cmessage}}</h2>
        </div>
    </template>

    <script src='../js/vue.js'></script>
    <script>
        //父传子:props
        const cpn = {
            template: '#cpn',
            //此类数组写法极少使用
            //props:['cmusics', 'cmessage']

            //此类对象属性最多使用,有两种方式
            props: {
                //1.限制类型
                // cmusics:Array,
                // cmessage:String

                //2.提供一些默认值，以及必传值
                cmusics:{
                    //限制类型
                    type:Array,
                    //设置默认值
                    default() {
                        return []
                    },
                    //必须传值
                    required:true
                },
                cmessage:{
                    type:String,
                    default:'数据未被接收!!!',
                    required:true
                }
            }
        }



        const app = new Vue({
            el: '#app',
            data: {
                musics: ['陈奕迅', '周杰伦', '张杰', '刘德华', '张学友'],
                message: '你好, 重庆对外经贸学院!'

            },
            components: {
                cpn
            },
            methods: {

            }
        })
    </script>
</body>

</html>